import React, {Component} from 'react'
import {Button} from '../button/Button'

export interface CardFooterProps extends React.HTMLAttributes<HTMLElement> {
  className?: string
  isButtonBlock?: boolean
  onClickCancel?: (evt?: any) => void
  onClickSave?: (evt?: any) => void
}

class CardFooter extends Component<CardFooterProps> {
  render(): React.ReactNode {
    const {className, isButtonBlock, onClickCancel, onClickSave} = this.props
    return (
      <div className={'card-footer ' + (className || '')}>
        {this.props.children}
        {isButtonBlock && (
          <div className={'footer-button'}>
            <Button
              color={'primary'}
              size={'sm'}
              style={'outline'}
              className={'mr-x4'}
              onClick={onClickCancel}>
              Отмена
            </Button>
            <Button color={'primary'} size={'sm'} onClick={onClickSave}>
              Сохранить
            </Button>
          </div>
        )}
      </div>
    )
  }
}

export default CardFooter
